package com.example.second_home_work

import android.annotation.SuppressLint
import android.os.Bundle
import android.widget.Button
import android.widget.ScrollView
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {
    @SuppressLint("WrongViewCast","SetTextI18n","MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        var cnt = 0
        val button1 = findViewById<Button>(R.id.button1)
        val scrollView1 = findViewById<ScrollView>(R.id.scrollView1)
        val textView1 = findViewById<TextView>(R.id.textView1)
        val text = StringBuilder()

        button1.setOnClickListener {
            text.append(getString(R.string.area1)).append(" ").append(cnt).append("\n")
            cnt++
            textView1.text = text.toString()
            scrollView1.fullScroll(ScrollView.FOCUS_DOWN)
        }

        val expert = ProgramAdviser(this)
        val button2 = findViewById<Button>(R.id.button2)
        val spinner = findViewById<Spinner>(R.id.spinner)
        val textView2 = findViewById<TextView>(R.id.textView2)
        button2.setOnClickListener {
            val selectedFeature = spinner.selectedItem.toString()
            textView2.text = expert.getLanguage(selectedFeature)
        }
    }
}






























